import request from "@/utils/request.js";
export const getheadapi = () => {
  return request.get("/home/category/head");
};
export const getbannerapi = (distributionSite) => {
  // const { distributionSite = "1" } = params;
  return request.get("/home/banner", {
    params: { distributionSite },
  });
};
export const getnewsapi = () => {
  return request.get("/home/new");
};
export const gethotapi = () => {
  return request.get("/home/hot");
};
export const getgoodsapi = () => {
  return request.get("/home/goods");
};
export const getcategroyapi = (id) => {
  return request.get("/category", {
    params: {
      id,
    },
  });
};
export const getsubcategoryapi = (id) => {
  return request.get("/category/sub/filter", {
    params: {
      id,
    },
  });
};
export const getSubCategoryAPI = (data) => {
  return request({
    url: "/category/goods/temporary",
    method: "POST",
    data,
  });
};
export const getDetail = (id) => {
  return request({
    url: "/goods",
    params: {
      id,
    },
  });
};
export const getHotGoodsAPI = ({ id, type, limit = 3 }) => {
  return request({
    url: "/goods/hot",
    params: {
      id,
      type,
      limit,
    },
  });
};
export const getloginapi = ({ account, password }) => {
  return request({
    url: "/login",
    method: "POST",
    data: {
      account,
      password,
    },
  });
};
export const insertcartapi = (skuId, count) => {
  return request({
    url: "/member/cart",
    method: "POST",
    data: {
      skuId,
      count,
    },
  });
};
export const getcartapi = () => {
  return request({
    url: "/member/cart",
    method: "get",
  });
};
export const delcartapi = (ids) => {
  return request({
    url: "/member/cart",
    method: "DELETE",
    data: {
      ids,
    },
  });
};
export const mergecartapi = (data) => {
  return request({
    url: "/member/cart/merge",
    method: "POST",
    data,
  });
};
export const checkoutapi = () => {
  return request({
    url: "/member/order/pre",
    method: "get",
  });
};
export const createorderapi = (data) => {
  return request({
    url: "/member/order",
    method: "post",
    data,
  });
};
export const payinfoapi = (id) => {
  return request({
    url: `/member/order/${id}`,
    method: "get",
  });
};
export const getLikeListAPI = ({ limit = 4 }) => {
  return request({
    url: "/goods/relevant",
    params: {
      limit,
    },
  });
};
export const getUserOrderApi = (params) => {
  return request({
    url: "/member/order",
    method: "GET",
    params,
  });
};
